import { BasicDrawer, useDrawerInner } from "@/components/Drawer";
import { BasicForm, FormSchema, useForm } from "@/components/Form";
// import { Select } from "antd";
import { useTranslation } from "react-i18next";
// const { Option } = Select;
let reload: Function;
let addFn: Function;
const index = (props: { register: Fn }) => {
	const { t } = useTranslation();
	const schemas: FormSchema[] = [
		{
			label: t("felix_ui.patient_ID"),
			field: "patientId",
			component: "Input"
		},
		{
			label: t("felix_ui.full_name"),
			field: "fullName",
			component: "Input"
		},
		{
			label: t("felix_ui.birthday"),
			field: "birthday",
			component: "Input"
		},
		{
			label: t("felix_ui.age"),
			field: "age",
			component: "Input"
		},
		{
			label: t("felix_ui.gender"),
			field: "gender",
			component: "Input"
		},
		{
			label: t("felix_ui.house_number"),
			field: "houseNumber",
			component: "Input"
		},
		{
			label: t("felix_ui.village_street"),
			field: "street",
			component: "Input"
		},
		{
			label: t("felix_ui.occupation"),
			field: "Occupation",
			component: "Input"
		},
		{
			label: t("felix_ui.province_city"),
			field: "Province",
			component: "Input"
		},
		{
			label: t("felix_ui.district"),
			field: "District",
			component: "Input"
		},
		{
			label: t("felix_ui.districtc_ward_commune"),
			field: "commune",
			component: "Input"
		},
		{
			label: t("felix_ui.ethnicity"),
			field: "Ethnicity",
			component: "Input"
		},
		{
			label: t("felix_ui.beneficiary"),
			field: "Beneficiary",
			component: "Input"
		},
		{
			label: t("felix_ui.card_numb"),
			field: "Card Number",
			component: "Input"
		},
		{
			label: t("felix_ui.doctor"),
			field: "Doctor",
			component: "Select"
		},
		{
			label: t("kevin_ui.home_phone"),
			field: "homePhone",
			component: "Input"
		},
		{
			label: t("kevin_ui.office_phone"),
			field: "officePhone",
			component: "Input"
		},
		{
			label: t("kevin_ui.mobile_phone"),
			field: "mobilePhone",
			component: "Input"
		},
		{
			label: t("kevin_ui.payment"),
			field: "payment",
			component: "Input"
		},
		{
			label: t("felix_ui.grp_email"),
			field: "email",
			component: "Input"
		},
		{
			label: t("felix_ui.transferDocument"),
			field: "transferDocument",
			component: "Select"
		},
		{
			label: t("kevin_ui.salary"),
			field: "salary",
			component: "Input"
		}
	];
	const [registerDrawer, { closeDrawer }] = useDrawerInner(props.register, data => {
		console.log("打开Drawer", data);
		reload = data.reload;
		addFn = data.addFn;
	});
	const [register, { validateFields }] = useForm({
		schemas,
		labelWidth: 120,
		baseColProps: { span: 12 }
	});
	const handleSubmit = async () => {
		const res = await validateFields();
		addFn(res);
		closeDrawer();
		reload();
	};
	return (
		<BasicDrawer showFooter={true} size="large" {...props} register={registerDrawer} ok={handleSubmit}>
			<BasicForm labelWrap={true} register={register}></BasicForm>
		</BasicDrawer>
	);
};
export default index;
